public class Test2 {
    //题目2 计算pai的值
    public static void main(String[] args) {
        double sum = 0.00,k = 1;
        int fas = 1,i = 1,count = 0;
        while(Math.abs(k)>=1e-5){
            k=(1.0/i)*fas;
            sum+=k;
            count++;
            i+=2;
            fas=-fas;
        }
        System.out.println("pai："+sum*4);
        System.out.println("项数为："+(count-1));
    }
}
